package loengud.w08;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

//creates a small window with a text and a button in it
public class HelloGraphics2 extends JPanel {
	static JFrame frame;

	public static void main(String[] args) {

		// create a new window and a new panel
		frame = new JFrame("HelloGraphics2");
		HelloGraphics2 panel = new HelloGraphics2();
		
		/*
		JLabel label = new JLabel("Hello graphical world!");
		panel.add(label);
*/
		// add panel to the center of window
		frame.getContentPane().add("Center", panel);

		// Set a window look-and-feel
		try {
			UIManager.setLookAndFeel//("javax.swing.plaf.metal.MetalLookAndFeel");
			//("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
			 ("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
			SwingUtilities.updateComponentTreeUI(frame);
			frame.pack();
		} catch (Exception exc) {
			System.err.println("Could not load!");
		}

		// react to window close, pack stuff, show out
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.pack(); // auto-size to window
		frame.setVisible(true); // make window visible
	} // -main

	// Class constructor: called when object is created
	public HelloGraphics2() {
		// create a label widget with text, put on panel
		JLabel label = new JLabel("Hello graphical world!");
		add(label);

		// Create and add a button to panel
		JButton button = new JButton("Press me, please!");
		add(button);

	}
}
